package com.fh_24.service;

import com.fh_24.bean.Emp;
import com.fh_24.mapper.EmpMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class EmpService {
    public static void main(String[] args) throws IOException {
        InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml");
        SqlSessionFactory fy = new SqlSessionFactoryBuilder().build(is);
        SqlSession sq = fy.openSession(true);
        EmpMapper mp = sq.getMapper(EmpMapper.class);
        List<Emp> emps = mp.selectAll();
        System.out.println(emps);
    }
}
